package org.gd.spring.redis;

import org.gd.hellojaxb.adapters.StringAdaptersFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.connection.jedis.JedisConnection;
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;

public class App {

    public static void main(String...a) {

        ApplicationContext ac = new ClassPathXmlApplicationContext("context.xml");
        JedisConnectionFactory jcf = ac.getBean("jedisConnectionFactory", JedisConnectionFactory.class);
        JedisConnection connection = jcf.getConnection();

        String key = "key";
        String value = String.valueOf(Math.random());
        connection.set(key.getBytes(), value.getBytes());
        System.out.println(new String(connection.get(key.getBytes())));

        connection.close();
        jcf.destroy();

        connection = jcf.getConnection();
        System.out.println(new String(connection.get(key.getBytes())));
    }
}
